package com.ruoyi.web.controller.production.regulator;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.service.regulator.IRegulatorAmountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.regulator.RegulatorPurchase;
import com.ruoyi.production.service.regulator.IRegulatorPurchaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调节剂购买信息Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/regulatorPurchase")
@Api(value = "调节剂购买",tags = "调节剂购买相关API")
public class RegulatorPurchaseController extends BaseController
{
    @Autowired
    private IRegulatorPurchaseService regulatorPurchaseService;
    @Autowired
    private IRegulatorAmountService regulatorAmountService;

    /**
     * 查询调节剂购买信息列表
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorPurchase:list')")
    @GetMapping("/list")
    @ApiOperation("获取调节剂购买表信息")
    @ApiImplicitParam(name = "regulatorPurchase",value = "调节剂购买实体类",paramType = "body", dataType = "RegulatorPurchase")
    public TableDataInfo list(RegulatorPurchase regulatorPurchase)
    {
        startPage();
        List<RegulatorPurchase> list = regulatorPurchaseService.selectRegulatorPurchaseList(regulatorPurchase);
        return getDataTable(list);
    }

    /**
     * 导出调节剂购买信息列表
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorPurchase:export')")
    @Log(title = "调节剂购买信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出调节剂购买表信息")
    @ApiImplicitParam(name = "regulatorPurchase",value = "调节剂购买实体类",paramType = "body", dataType = "RegulatorPurchase")
    public AjaxResult export(RegulatorPurchase regulatorPurchase)
    {
        List<RegulatorPurchase> list = regulatorPurchaseService.selectRegulatorPurchaseList(regulatorPurchase);
        ExcelUtil<RegulatorPurchase> util = new ExcelUtil<RegulatorPurchase>(RegulatorPurchase.class);
        return util.exportExcel(list, "调节剂购买信息数据");
    }

    /**
     * 获取调节剂购买信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorPurchase:query')")
    @GetMapping(value = "/{regulatorPurchaseId}")
    @ApiOperation("获取调节剂购买表单个信息")
    @ApiImplicitParam(name = "regulatorPurchaseId",value = "调节剂购买实体类主键",paramType = "path", dataType = "Long")
    public AjaxResult getInfo(@PathVariable("regulatorPurchaseId") Long regulatorPurchaseId)
    {
        return AjaxResult.success(regulatorPurchaseService.selectRegulatorPurchaseById(regulatorPurchaseId));
    }

    /**
     * 新增调节剂购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorPurchase:add')")
    @Log(title = "调节剂购买信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增调节剂购买表信息")
    @ApiImplicitParam(name = "regulatorPurchase",value = "调节剂购买实体类",paramType = "body", dataType = "RegulatorPurchase")
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody RegulatorPurchase regulatorPurchase)
    {
        return toAjax(regulatorPurchaseService.insertPurchaseUpdateAmount(regulatorPurchase));
    }

    /**
     * 修改调节剂购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorPurchase:edit')")
    @Log(title = "调节剂购买信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改调节剂购买表信息")
    @ApiImplicitParam(name = "regulatorPurchase",value = "调节剂购买实体类",paramType = "body", dataType = "RegulatorPurchase")
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody RegulatorPurchase regulatorPurchase)
    {
        return toAjax(regulatorPurchaseService.updateRegulatorPurchase(regulatorPurchase));
    }

    /**
     * 删除调节剂购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:regulatorPurchase:remove')")
    @Log(title = "调节剂购买信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{regulatorPurchaseIds}")
    public AjaxResult remove(@PathVariable Long[] regulatorPurchaseIds)
    {
        return toAjax(regulatorPurchaseService.deleteRegulatorPurchaseByIds(regulatorPurchaseIds));
    }
}
